package com.cs.study.homework._0228;

public enum PayType {

    ALIPAY(1, "支付宝"),
    APPLEPAY(2, "苹果支付"),
    WECHAT(3, "微信支付");
    int id;
    String name;

    PayType(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "PayType{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }

    public static PayType findById(int id) {
        for (PayType type : PayType.values()) {
            if (type.getId() == id) {
                return type;
            }
        }
        return null;
    }
}
